<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../lib/layui-v2.6.3/css/layui.css" media="all">
    <style>
        .outBox{
            width: calc(100% - 50px);
            height: 100%;
        }
         .layui-form-item{
            margin-bottom: 0;
        }
        .layui-form-label {
            line-height: 54px;
            width: 50px;
        }
        .layui-inline{
            line-height: 77px;
        }
        .queryBtn{
            margin-bottom: 8px;
        }
    </style>
</head>
<body>
    <div class="outBox">
        <div class="layui-form">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">日期</label>
                    <div class="layui-inline" id="time">
                        <div class="layui-input-inline">
                            <input type="text" autocomplete="off" id="currentTime" class="layui-input" placeholder="开始日期">
                        </div>
                    </div>
                </div>
                <button type="button" class="layui-btn queryBtn" id="queryBtn">查询</button>
            </div>
        </div>
        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
        <script type="text/html" id="currentTableBar">
            {{#  if(d.warn == 1){ }}
            <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="edit">绿色预警</a>
            {{#  } else  if(d.warn ==2){ }}
            <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete">红色预警</a>
            {{#  } }}
            <!-- <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="edit">绿色预警</a>
            <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete">红色预警</a> -->
        </script>
    </div>
<script src="../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    layui.use(['laydate', 'table'], function () {
        var $ = layui.jquery,
            laydate = layui.laydate,
            table = layui.table;
        laydate.render({
            elem: '#currentTime'
            ,format: 'yyyy-MM-dd'
        });
        table.render({
            elem: '#currentTableId',
            url: '../api/table.json',
            toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', 'exports', 'print'],
            cols: [[
                {field: 'time', minWidth: 150, title: '时间', sort: true},
                {field: 'station', minWidth: 150, title: '位置'},
                {field: 'concentration', minWidth: 150, title: '浓度'},
                {field: 'warn', minWidth: 150, title: '预警状况'},
                {title: '操作', minWidth: 150, toolbar: '#currentTableBar', align: "center"}
            ]],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 15,
            page: false,
            skin: 'line'
        });

        // // 监听搜索操作
        // form.on('submit(data-search-btn)', function (data) {
        //     var result = JSON.stringify(data.field);
        //     layer.alert(result, {
        //         title: '最终的搜索信息'
        //     });

        //     //执行搜索重载
        //     table.reload('currentTableId', {
        //         page: {
        //             curr: 1
        //         }
        //         , where: {
        //             searchParams: result
        //         }
        //     }, 'data');

        //     return false;
        // });

        /**
         * toolbar监听事件
         */
        // table.on('toolbar(currentTableFilter)', function (obj) {
        //     if (obj.event === 'add') {  // 监听添加操作
        //         var index = layer.open({
        //             title: '添加用户',
        //             type: 2,
        //             shade: 0.2,
        //             maxmin:true,
        //             shadeClose: true,
        //             area: ['100%', '100%'],
        //             content: '../page/table/add.html',
        //         });
        //         $(window).on("resize", function () {
        //             layer.full(index);
        //         });
        //     } else if (obj.event === 'delete') {  // 监听删除操作
        //         var checkStatus = table.checkStatus('currentTableId')
        //             , data = checkStatus.data;
        //         layer.alert(JSON.stringify(data));
        //     }
        // });
    });
</script>

</body>
</html>